package com.fanjia.crm.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import java.util.List;

/**
 * Created by FanJia on 2020/9/20 19:12
 */
@Data
public class User {
    private int id;
    private String username;
    private String password;
    private int locked;
    @JsonIgnore
    private List<Role> roles;

    public String getRoleNames(){
        StringBuffer sb = new StringBuffer();
        sb.append("[");
        if(roles.size()>0){
            for(Role role : roles){
                sb.append(role.getName() + ",");
            }
            sb.deleteCharAt(sb.length()-1);
        }


        sb.append("]");
        return sb.toString();
    }
}
